package com.suntek.logback.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author： wuyuhao
 * @version： 2019/02/ 15
 * @since： 2019/02/15
 */
@RestController
@Slf4j
public class TestController {
    @GetMapping("/test")
    public String test(){
        long startTime = System.currentTimeMillis();
        log.debug("debug");
        log.warn("warn");
        log.error("error");
        log.info("info");

        try {
            exception();
        } catch (Exception e) {
            log.error("方法调用出现异常:{}",e.toString());
        }
        log.debug("方法耗时:{}ms",System.currentTimeMillis()-startTime);
        return "helloWorld";
    }

    public void exception(){
        throw new RuntimeException("异常");
    }
}
